/*
 * @Author: AHANG
 * @Date: 2022-06-16 11:24:11
 * @LastEditors: AHANG
 * @LastEditTime: 2022-07-09 15:24:04
 * @Description:    axios 接口同一化
 */

//引入模块
import requests from "./request";

// /api/user/getCaptcha  get 无参数
//登录
export const login = (obj) => {
  return requests({
    url: "api/user/login",
    method: "post",
    data: {
      user: obj.user,
      pass: obj.pass,
    },
  });
};

//查
export const searchBook = () => {
  return requests({
    url: "/api/user/searchBook",
    method: "get",
  });
};
//删
export const deleteBook = (id) => {
  return requests({
    url: "/api/user/deleteBook",
    method: "delete",
    data: {
      id: id,
    },
  });
};
//改
export const updateBook = (obj) => {
  return requests({
    url: "/api/user/updateBook",
    method: "post",
    data: {
      id: obj.id,
      author: obj.author,
      press: obj.press,
      name: obj.name,
      date: obj.date,
      price: obj.price,
      number: obj.number,
    },
  });
};
//增
export const addBook = (obj) => {
  return requests({
    url: "api/user/addBook",
    method: "post",
    data: {
      author: obj.author,
      press: obj.press,
      name: obj.name,
      date: obj.date,
      price: obj.price,
      number: obj.number,
    },
  });
};
